<?php
/**
 * Description
 *
 * PHP version 7
 *
 * @category Custom
 * @package  Custom
 * @author   ryu <mo5467@126.com>
 * @date     2020-04-25 12:50:37
 * @lastTime 2020-05-01 23:02:00
 * @license  https://opensource.org/licenses/MIT MIT License
 * @link     none
 */

namespace Design\Structural\Registry;

use InvalidArgumentException;

abstract class Registry
{
    public const LOGGER = 'logger';

    private static $services = [];

    private static $allowKeys = [self::LOGGER];


    public static function set(string $key, Service $service)
    {
        if (in_array($key, self::$allowKeys) === false) {
            throw new InvalidArgumentException('Invalid key #'.$key);
        }

        self::$services[$key] = $service;

    }//end set()


    public static function get(string $key): Service
    {
        if (in_array($key, self::$allowKeys) === false || isset(self::$services[$key]) === false) {
            throw new InvalidArgumentException('Invalid key #'.$key);
        }

        return self::$services[$key];

    }//end get()


}//end class
